﻿using Appraisal_System.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Appraisal_System
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
        }

        private void FrmMain_Load(object sender, EventArgs e)
        {
            Form form = FormFactory<String>.CreateFactory("FrmUserManager");
            /* frmUserManager = new FrmUserManager();
             //将FrmUserM 窗口放入 FrmMain 窗口
             frmUserManager.MdiParent = this;
             frmUserManager.Parent = splitContainer1.Panel2;
             //展示此窗口
             frmUserManager.Show();*/

           // Form form = FormFactory.CreateFactory(0);
            form.MdiParent = this;
            form.Parent = splitContainer1.Panel2;
            form.Show();
        }

        private void splitContainer1_Panel2_Paint(object sender, PaintEventArgs e)
        {

        }

        //观察者模式，观察是否点击节点
        private void trvMenu_AfterSelect(object sender, TreeViewEventArgs e)
        {
            foreach (TreeNode node in trvMenu.Nodes)
            {
                node.BackColor = Color.White;
                node.ForeColor = Color.Black;
            }
            e.Node.BackColor = SystemColors.Highlight;
            e.Node.ForeColor = Color.White;

            //根据（数据）Tag信息创建窗体
            Form form = FormFactory<String>.CreateFactory(e.Node.Tag.ToString());
            form.MdiParent = this;
            form.Parent = splitContainer1.Panel2;
            form.Show();
        }
    }
}
